﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Collections;

namespace GregTech_Resource
{
    class Lode
    {
        private string Name_;
        private Ore[] Source_;
        private byte[] Height_;
        private byte Possibility_;
        private byte Density_;
        private byte Size_;
        private bool[] World_;
        private List<string> Elements_;
        private List<string> MainElements_;

        static List<Lode> LodeTable = new List<Lode>();

        /// <summary>
        /// 初始化矿脉数据对象。
        /// </summary>
        /// <param name="SrcData">包含全部矿脉信息的字符串</param>
        public Lode(string SrcData)
        {
            string tmp = "";
            int i = 0;
            Source_ = new Ore[4];
            Height_ = new byte[2];
            World_ = new bool[3];
            Elements_ = new List<string>();
            MainElements_ = new List<string>();

            foreach(char c in SrcData)
            {
                if (c == ' ')
                {
                    switch (i)
                    {
                        case 0:
                            Name_ = tmp;
                            break;
                        case 1:
                            Source_[0] = Ore.OreTable[Convert.ToByte(tmp) - 1];
                            break;
                        case 2:
                            Source_[1] = Ore.OreTable[Convert.ToByte(tmp) - 1];
                            break;
                        case 3:
                            Source_[2] = Ore.OreTable[Convert.ToByte(tmp) - 1];
                            break;
                        case 4:
                            Source_[3] = Ore.OreTable[Convert.ToByte(tmp) - 1];
                            break;
                        case 5:
                            Height_[0] = Convert.ToByte(tmp);
                            break;
                        case 6:
                            Height_[1] = Convert.ToByte(tmp);
                            break;
                        case 7:
                            Possibility_ = Convert.ToByte(tmp);
                            break;
                        case 8:
                            Density_ = Convert.ToByte(tmp);
                            break;
                        case 9:
                            Size_ = Convert.ToByte(tmp);
                            break;
                        case 10:
                            World_[0] = Convert.ToBoolean(tmp);
                            break;
                        case 11:
                            World_[1] = Convert.ToBoolean(tmp);
                            break;
                        case 12:
                            World_[2] = Convert.ToBoolean(tmp);
                            break;
                        case 13:
                            MainElements_.Add(tmp);
                            break;
                    }
                    tmp = "";
                    i++;
                }
                else if(c == ',')
                {
                    MainElements_.Add(tmp);
                    tmp = "";
                }
                else
                    tmp += c;
            }

            if (MainElements_[0] == "")
                MainElements_.Clear();

            foreach (Ore o in Source_)
            {
                foreach (string s in o.Elements)
                    if (!Elements_.Contains(s))
                        Elements_.Add(s);
            }
            foreach (Ore o in Source_)
                if (!o.InLodes.Contains(this))
                    o.InLodes.Add(this);
        }

        /// <summary>
        /// 加载存储的矿脉数据。
        /// </summary>
        public static void LoadLode()
        {
            #region 矿脉原始数据
            string[] SrcLode = new string[30];
            SrcLode[1 - 1] = "褐煤矿脉 1 1 1 2 50 130 160 8 32 True False False C ";
            SrcLode[2 - 1] = "煤矿脉 2 2 2 1 50 80 80 6 32 True False False C ";
            SrcLode[3 - 1] = "磁铁矿脉 3 3 4 5 50 120 160 3 32 True True False Fe,V ";
            SrcLode[4 - 1] = "金矿脉 3 3 5 6 60 80 160 3 32 True False False Fe,Au,V ";
            SrcLode[5 - 1] = "铁矿脉 7 8 9 20 10 40 120 4 24 True True False Fe,Cu,C ";
            SrcLode[6 - 1] = "锡石矿脉 10 10 11 10 40 120 50 5 24 True False False Sn ";
            SrcLode[7 - 1] = "黝铜矿脉 12 12 13 14 80 120 70 4 24 True True False Cu,Sb,Fe,S ";
            SrcLode[8 - 1] = "下界石英矿脉 15 15 15 15 40 80 80 5 24 False True False  ";
            SrcLode[9 - 1] = "硫矿脉 16 16 17 18 5 20 100 5 24 False True False S,Fe,Zn ";
            SrcLode[10 - 1] = "铜矿脉 19 4 17 13 10 30 80 4 24 True True False Cu,Fe ";
            SrcLode[11 - 1] = "铝土矿脉 21 21 22 23 50 90 80 4 24 True False False Al,Ti,Fe ";
            SrcLode[12 - 1] = "盐矿脉 25 24 26 27 50 60 50 3 24 True False False Cl,K,Na,Li,F,Si ";
            SrcLode[13 - 1] = "红石矿脉 28 28 29 30 10 40 60 3 24 True True False Fe,Cr,Al,Hg,Si ";
            SrcLode[14 - 1] = "皂石矿脉 31 32 70 39 10 40 40 3 16 True False False Mg,Si,Ni,Al,K ";
            SrcLode[15 - 1] = "镍矿脉 37 33 38 39 10 40 40 3 16 True True True Ni,Co,S,As ";
            SrcLode[16 - 1] = "铂矿脉 40 41 42 43 40 50 5 3 16 True False True Pt,Pd,Ir,Ni,S ";
            SrcLode[17 - 1] = "沥青铀矿矿脉 46 46 45 44 10 40 40 3 16 True False False U-238,Th,Pb ";
            SrcLode[18 - 1] = "钚矿脉 44 44 47 45 20 30 10 3 16 True False False U-238,Pu-244,Th,Pb ";
            SrcLode[19 - 1] = "独居石矿脉 34 34 35 36 20 40 30 3 16 True False False Ce,Nd,La,F,C ";
            SrcLode[20 - 1] = "钼矿脉 48 50 49 51 20 50 5 3 16 True False True Mo,Pb,S,Ca ";
            SrcLode[21 - 1] = "钨酸盐矿脉 52 52 53 54 20 50 10 3 16 True False True W,Li ";
            SrcLode[22 - 1] = "蓝宝石矿脉 56 57 55 58 10 40 60 3 16 True False False Al,Fe,Mg,Si ";
            SrcLode[23 - 1] = "锰矿脉 59 60 61 62 20 30 20 3 16 True False True Mn,Fe,Ca,Al,Ta,Si ";
            SrcLode[24 - 1] = "石英矿脉 63 84 64 64 40 80 60 3 16 True False False Ba,S ";
            SrcLode[25 - 1] = "钻石矿脉 65 65 66 2 5 20 40 2 16 True False False C ";
            SrcLode[26 - 1] = "橄榄石矿脉 67 68 69 70 10 40 60 3 16 True False True Mg,Fe,Al,Si,K ";
            SrcLode[27 - 1] = "磷灰石矿脉 71 71 72 73 40 60 60 3 16 True False False P,Ca,Cl ";
            SrcLode[28 - 1] = "方铅矿脉 74 74 75 76 30 60 40 5 16 True False False Pb,Ag,S ";
            SrcLode[29 - 1] = "青金石矿脉 77 78 79 80 20 50 40 5 16 True False True Al,Na,Ca,Si,Cl ";
            SrcLode[30 - 1] = "铍矿脉 81 81 82 83 5 30 30 3 16 True False True Be,Th,Al,Si ";
            #endregion
            foreach (string s in SrcLode)
                LodeTable.Add(new Lode(s));
        }

        /// <summary>
        /// 搜索指定的矿脉名称。
        /// </summary>
        /// <param name="LodeName">需要搜索的矿脉名</param>
        /// <returns>搜索到的数据结果</returns>
        public static List<Lode> SearchLode(string LodeName)
        {
            List<Lode> Result = new List<Lode>();
            foreach (Lode OreData in LodeTable)
            {
                if (OreData.Name.Contains(LodeName) ||
                    OreData.Source[0].Name.Contains(LodeName) ||
                    OreData.Source[1].Name.Contains(LodeName) ||
                    OreData.Source[2].Name.Contains(LodeName) ||
                    OreData.Source[3].Name.Contains(LodeName))
                    Result.Add(OreData);
                else
                {
                    foreach (string s in OreData.Elements)
                    {
                        if (s == "U-238" && LodeName.Equals("U", StringComparison.InvariantCultureIgnoreCase))
                        {
                            Result.Add(OreData);
                            break;
                        }
                        if (s == "Pu-244" && LodeName.Equals("Pu", StringComparison.InvariantCultureIgnoreCase))
                        {
                            Result.Add(OreData);
                            break;
                        }
                        if (s.Equals(LodeName, StringComparison.InvariantCultureIgnoreCase))
                        {
                            Result.Add(OreData);
                            break;
                        }
                    }
                }
            }
            return Result;
        }

        /// <summary>
        /// 将矿脉数据格式化为可直接输出的字符串
        /// </summary>
        /// <param name="data">待格式化的矿脉数据</param>
        /// <returns></returns>
        public string OutputLode()
        {
            string str = "";
            string World = "";
            if (this.World[0])
                World += "主世界  ";
            if (this.World[1])
                World += "下界  ";
            if (this.World[2])
                World += "末路之地";

            str =
                "矿脉名称：" + this.Name + "\n" +
                "上层矿石：" + this.Source[0].Name + "\n" +
                "下层矿石：" + this.Source[1].Name + "\n" +
                "中层矿石：" + this.Source[2].Name + "\n" +
                "散乱分布：" + this.Source[3].Name + "\n\n" +
                "生成高度：" + this.Height[0] + "~" +
                              this.Height[1] + "\n" +
                "综合发现几率：" + ((double)this.Possibility / 18.5).ToString().Remove(4) + "%\n" +
                "生成所在：" + World + "\n";

            str += "主要元素：";
            if (this.MainElements.Count != 0)
            {
                for (int i = 0; i < this.MainElements.Count - 1; ++i)
                    str += (this.MainElements[i] + ", ");
                str += this.MainElements[this.MainElements.Count - 1] + "\n";
            }
            else
                str += "-" + "\n";

            str += "全部元素：";
            if (this.Elements.Count != 0)
            {
                for (int i = 0; i < this.Elements.Count - 1; ++i)
                    str += (this.Elements[i] + ", ");
                str += this.Elements[this.Elements.Count - 1] + "\n";
            }
            else
                str += "-" + "\n";

            return str;
        }

        #region 为Lode中的数据构建的访问器
        public string Name
        {
            get { return Name_; }
            set { Name_ = Name; }
        }
        public Ore[] Source
        {
            get { return Source_; }
            set { Source_ = Source; }
        }
        public byte[] Height
        {
            get { return Height_; }
            set { Height_ = Height; }
        }
        public byte Possibility
        {
            get { return Possibility_; }
            set { Possibility_ = Possibility; }
        }
        public byte Density
        {
            get { return Density_; }
            set { Density_ = Density; }
        }
        public byte Size
        {
            get { return Size_; }
            set { Size_ = Size; }
        }
        public bool[] World
        {
            get { return World_; }
            set { World_ = World; }
        }
        public List<string> Elements
        {
            get { return Elements_; }
            set { Elements_ = Elements; }
        }
        public List<string> MainElements
        {
            get { return MainElements_; }
            set { MainElements_ = MainElements; }
        }
        #endregion
    }

    class Ore
    {
        private string Name_;
        private byte Level_;
        private List<string> MainElements_;
        private List<string> Elements_;
        private List<Lode> InLodes_;
        private string[] Byproducts_;
        private string Remarks_;

        static List<Ore> OreTable_ = new List<Ore>();

        /// <summary>
        /// 初始化矿石数据对象。
        /// </summary>
        /// <param name="SrcData">包含全部矿石信息的字符串</param>
        public Ore(string SrcData)
        {
            MainElements_ = new List<string>();
            Elements_ = new List<string>();
            InLodes_ = new List<Lode>();
            Byproducts_ = new string[3];
            string tmp = "";
            Remarks_ = "";
            int i = 0;

            foreach(char c in SrcData)
            {
                if (c == ' ')
                {
                    switch (i)
                    {
                        case 0:
                            Name_ = tmp;
                            break;
                        case 1:
                            if (tmp.Length != 0) MainElements_.Add(tmp);
                            break;
                        case 2:
                            Level_ = Convert.ToByte(tmp);
                            break;
                        case 3:
                            Byproducts_[0] = tmp;
                            break;
                        case 4:
                            Byproducts_[1] = tmp;
                            break;
                        case 5:
                            Byproducts_[2] = tmp;
                            break;
                        case 6:
                            Elements_.Add(tmp);
                            break;
                        case 7:
                            Remarks_ = tmp;
                            break;
                    }
                    ++i;
                    tmp = "";
                }
                else if (c == ',' && i == 1)
                {
                    MainElements_.Add(tmp);
                    tmp = "";
                }
                else if (c == ',' && i == 6)
                {
                    Elements_.Add(tmp);
                    tmp = "";
                }
                else
                    tmp += c;
                if (Byproducts[0] == "")
                    Byproducts[0] = "-";
                if (Byproducts[1] == "")
                    Byproducts[1] = "-";
                if (Byproducts[2] == "")
                    Byproducts[2] = "-";
            }
        }

        /// <summary>
        /// 加载存储的矿石数据。
        /// </summary>
        public static void LoadOre()
        {
            #region 矿石原始数据
            string[] SrcOre = new string[84];
            SrcOre[1 - 1] = "褐煤 C 0 煤   C  ";
            SrcOre[2 - 1] = "煤 C 1 褐煤 Th  C  ";
            SrcOre[3 - 1] = "磁铁 Fe 2 Fe Au  Fe,Au  ";
            SrcOre[4 - 1] = "铁 Fe 2 Ni Sn  Fe,Ni,Sn  ";
            SrcOre[5 - 1] = "钒磁铁 V,Fe 2 磁铁 V  V,Fe  ";
            SrcOre[6 - 1] = "金 Au 2 Cu Ni  Au,Cu,Ni  ";
            SrcOre[7 - 1] = "褐铁 Fe 1 孔雀石 黄色褐铁  Fe,Cu,C  ";
            SrcOre[8 - 1] = "黄色褐铁 Fe 2 Ni 褐铁 Co Fe,Co,Ni  ";
            SrcOre[9 - 1] = "皮带纹铁 Fe 2    Fe  ";
            SrcOre[10 - 1] = "锡 Sn 1 Fe Zn  Sn,Fe,Zn  ";
            SrcOre[11 - 1] = "锡石 Sn 1 Sn   Sn  ";
            SrcOre[12 - 1] = "黝铜 Cu,Sb,Fe,S 2 Sb Zn  Cu,Sb,Fe,S,Zn  ";
            SrcOre[13 - 1] = "铜 Cu 1 Co Au Ni Cu,Co,Au,Ni  ";
            SrcOre[14 - 1] = "辉锑 Sb 2 Sb   Sb,S  ";
            SrcOre[15 - 1] = "下界石英 下界石英 1    -  ";
            SrcOre[16 - 1] = "硫 S 2 S   S  ";
            SrcOre[17 - 1] = "黄铁 Fe,S 1 S 磷 Fe Fe,S,Ca,P  ";
            SrcOre[18 - 1] = "闪锌 Zn,S 1 黄色石榴石 Cd Ga Zn,S,Ca,Fe,Al,Cr,Si,Cd,Ga  ";
            SrcOre[19 - 1] = "黄铜 Cu,Fe,S 1 黄铁 Co Cd Cu,Fe,S,Co,Cd,Au  ";
            SrcOre[20 - 1] = "孔雀石 Cu,C 2 Cu 褐铁 方解石 Cu,C,Fe,Ca  ";
            SrcOre[21 - 1] = "铝土 Al,Ti 1 钙铝榴石 Ti Ga Al,Ti,Ga,Ca,Si  ";
            SrcOre[22 - 1] = "铝 Al 2 铝土   Al,Ti  ";
            SrcOre[23 - 1] = "钛铁 Fe,Ti 3 Fe Ti  Fe,Ti  ";
            SrcOre[24 - 1] = "盐 Na,Cl 1 岩盐   Na,Cl,K  ";
            SrcOre[25 - 1] = "岩盐 K,Cl 1 盐   K,Cl,Na  ";
            SrcOre[26 - 1] = "锂云母 K,Li,Al 2 Li Cs  K,Li,Al,Cs  ";
            SrcOre[27 - 1] = "锂辉石 Li,Al,Si 2 Al Li  Li,Al,Si  ";
            SrcOre[28 - 1] = "红石 Si,黄铁,红宝石,Hg 2 闪锌 稀土 荧石 Si,Fe,Cr,Al,Hg,S,Zn,Au,Nd,Y,La,Ce,Cd,Cs  ";
            SrcOre[29 - 1] = "红宝石 Cr,Al 2 Cr 红色石榴石  Cr,Al,Mg,Fe,Mn,Si  ";
            SrcOre[30 - 1] = "朱砂 Hg,S 1 红石 S 荧石 Hg,S,Si,Fe,Cr,Al  ";
            SrcOre[31 - 1] = "滑石矿石(皂石) Mg,Si 1    Mg,Si  ";
            SrcOre[32 - 1] = "滑石 Mg,Si 2    Mg,Si  ";
            SrcOre[33 - 1] = "镍 Ni 2 Co Pt Fe Ni,Co,Pt,Fe  ";
            SrcOre[34 - 1] = "氟碳铈镧 Ce,C,F 2 Nd 稀土  Ce,C,F,Nd,Y,La,Ce,Cd,Cs  ";
            SrcOre[35 - 1] = "独居石 稀土,磷酸盐 1 Th Nd 稀土 P,Th,Nd,Y,La,Ce,Cd,Cs  ";
            SrcOre[36 - 1] = "钕 Nd 2 独居石 稀土  Nd,P,Y,La,Ce,Cd,Cs  ";
            SrcOre[37 - 1] = "硅镁镍 Ni 3 Ni   Ni  ";
            SrcOre[38 - 1] = "辉钴 Co,As,S 1 Co   Co,As,S  ";
            SrcOre[39 - 1] = "镍黄铁 Ni,S 2 Fe S Co Ni,S,Fe,Co  ";
            SrcOre[40 - 1] = "铂(硫铂) Pt,Ni,S 1 Pd Ni Ir Pt,Ni,S,Pd,Ir  ";
            SrcOre[41 - 1] = "钯 Pd 2    Pd  ";
            SrcOre[42 - 1] = "铂 Pt 2 Ni Ir  Pt,Ni,Ir  ";
            SrcOre[43 - 1] = "铱 Ir 4 Pt Os  Ir,Pt,Os  ";
            SrcOre[44 - 1] = "沥青铀(晶铀) Uranite,Th,Pb 3 Th U-238 Pb U-238,Th,Pb  ";
            SrcOre[45 - 1] = "铀-238 U-238 3 Pb Pu-244 Th U-238,Pb,Pu-244,Th  ";
            SrcOre[46 - 1] = "沥青铀(非晶铀) U-238 3 U-238 Th Pu-244 U-238,Th,Pu-244  ";
            SrcOre[47 - 1] = "钚-244 Pu-244 3 U-238 Pb  Pu-244,U-238,Pb 辐射 ";
            SrcOre[48 - 1] = "钼铅 Pb,Mo 3    Pb,Mo  ";
            SrcOre[49 - 1] = "钼 Mo 2    Mo  ";
            SrcOre[50 - 1] = "辉钼 Mo,S 2 Mo   Mo,S  ";
            SrcOre[51 - 1] = "钼钨钙 Ca,Mo 2    Ca,Mo  ";
            SrcOre[52 - 1] = "白钨 W,Ca 3 Mn Mo Ca W,Ca,Mn,Mo  ";
            SrcOre[53 - 1] = "钨酸盐 W,Li 3 Mn Ag Li W,Li,Mn,Ag  ";
            SrcOre[54 - 1] = "锂 Li 2 Li   Li  ";
            SrcOre[55 - 1] = "蓝宝石 Al 2 Al 绿色蓝宝石  Al  ";
            SrcOre[56 - 1] = "铁铝榴石 Al,Fe,Si 1 红色石榴石 Al  Al,Fe,Si,Mg,Mn  ";
            SrcOre[57 - 1] = "镁铝榴石 Al,Mg,Si 2 红色石榴石 Mg  Al,Mg,Si,Fe,Mn  ";
            SrcOre[58 - 1] = "绿色蓝宝石 Al 2 Al 蓝宝石  Al  ";
            SrcOre[59 - 1] = "钙铝榴石 Ca,Al 1 黄色石榴石 Ca  Ca,Al,Si,Fe,Cr  ";
            SrcOre[60 - 1] = "锰铝榴石 Al,Mn,Si 2 红色石榴石 Mn  Al,Mn,Si,Fe,Mg  ";
            SrcOre[61 - 1] = "软锰 Mn 2 Mn   Mn  ";
            SrcOre[62 - 1] = "钽铁 Mn,Ta 3 Mn Nb Ta Mn,Ta,Nb  ";
            SrcOre[63 - 1] = "石英岩 石英岩 1 塞特斯石英 重晶石  Ba,S  ";
            SrcOre[64 - 1] = "塞特斯石英 塞特斯石英 1 石英岩 重晶石  Ba,S  ";
            SrcOre[65 - 1] = "石墨 石墨 2 C   C  ";
            SrcOre[66 - 1] = "钻石 C 3 石墨   C  ";
            SrcOre[67 - 1] = "膨润土 Na,Mg,Si 2 Al Ca Mg Na,Mg,Si,Ca  ";
            SrcOre[68 - 1] = "菱镁 Mg,C 2 Mg   Mg,C  ";
            SrcOre[69 - 1] = "橄榄石 Mg,Fe,Si 2 橄榄石   Mg,Fe,Si,Al  ";
            SrcOre[70 - 1] = "海绿石 K,Mg,Al 2 Na Al Fe K,Mg,Al,Na,Fe  ";
            SrcOre[71 - 1] = "磷灰石 Ca,磷酸盐,Cl 1 磷   Ca,P,Cl  ";
            SrcOre[72 - 1] = "磷 Ca,磷酸盐 2 磷灰石   Ca,P,Cl  ";
            SrcOre[73 - 1] = "磷酸盐 磷酸盐 1 磷酸盐   P  ";
            SrcOre[74 - 1] = "方铅 Pb,Ag,S 3 S Ag Pb Pb,Ag,S  ";
            SrcOre[75 - 1] = "银 Ag 2 Pb S  Ag,Pb,S  ";
            SrcOre[76 - 1] = "铅 Pb 1 Ag S  Pb,Ag,S  ";
            SrcOre[77 - 1] = "青金石化合物 Al,Si,Ca,Na 1 方钠石 青金石  Al,Si,Ca,Na,Cl,Fe,S,C  ";
            SrcOre[78 - 1] = "方钠石 Al,Si,Na,Cl 1 青金石化合物 青金石  Al,Si,Na,Cl,Ca,Fe,S  ";
            SrcOre[79 - 1] = "青金石 青金石化合物,方钠石,黄铁,方解石 1 青金石化合物 方钠石 黄铁 Al,Si,Ca,Na,Cl,Fe,S,C  ";
            SrcOre[80 - 1] = "方解石 Ca,C 1 钙铁榴石 孔雀石  Ca,C,Fe,Si,Cu  ";
            SrcOre[81 - 1] = "铍 Be 2 绿宝石   Be,Al,Si  ";
            SrcOre[82 - 1] = "绿宝石 Be,Al,Si 2 Be Al  Be,Al,Si  ";
            SrcOre[83 - 1] = "钍 Th 2 U-238 Pb  Th,U-238,Pb  ";
            SrcOre[84 - 1] = "重晶石 Ba,S 2    Ba,S  ";
            #endregion
            foreach (string s in SrcOre)
                OreTable.Add(new Ore(s));
        }

        /// <summary>
        /// 搜索指定的矿石名称。
        /// </summary>
        /// <param name="LodeName">需要搜索的矿石名</param>
        /// <returns>搜索到的数据结果</returns>
        public static List<Ore> SearchOre(string OreName)
        {
            List<Ore> Result = new List<Ore>();
            foreach (Ore OreData in OreTable)
            {
                if (OreData.Name.Contains(OreName))
                    Result.Add(OreData);
                else
                {
                    foreach (string s in OreData.Elements)
                    {
                        if (s == "U-238" && OreName.Equals("U", StringComparison.InvariantCultureIgnoreCase))
                        {
                            Result.Add(OreData);
                            break;
                        }
                        if (s == "Pu-244" && OreName.Equals("Pu", StringComparison.InvariantCultureIgnoreCase))
                        {
                            Result.Add(OreData);
                            break;
                        }
                        if (s.Equals(OreName, StringComparison.InvariantCultureIgnoreCase))
                        {
                            Result.Add(OreData);
                            break;
                        }
                    }
                }
            }
            return Result;
        }

        /// <summary>
        /// 将矿石数据格式化为可直接输出的字符串
        /// </summary>
        /// <param name="data">待格式化的矿石数据</param>
        /// <returns></returns>
        public string OutputOre()
        {
            string str;
            int n = 0;

            str =
                "矿石名称：" + this.Name + "\n" +
                "挖掘等级：" + this.Level + "\n\n";

            if (this.MainElements.Count != 0)
            {
                str += "主要元素：";
                for (int i = 0; i < this.MainElements.Count - 1; ++i)
                    str += this.MainElements[i] + ", ";
                str += this.MainElements[this.MainElements.Count - 1] + "\n";
            }

            if (this.Elements.Count != 0)
            {
                str += "全部元素：";
                for (int i = 0; i < this.Elements.Count - 1; ++i)
                    str += this.Elements[i] + ", ";
                str += this.Elements[this.Elements.Count - 1] + "\n";
            }

            str +=
                "第一副产物：" + this.Byproducts[0] + "\n" +
                "第二副产物：" + this.Byproducts[1] + "\n" +
                "第三副产物：" + this.Byproducts[2] + "\n\n";

            str += "所在矿脉：";
            foreach (Lode l in InLodes)
            {
                str += l.Name;
                ++n;
                if (n < InLodes.Count) str += ", ";
            }
            if (n == 0)
                str += "-";

            if (this.Remarks.Length != 0)
                str += "\n备注：" + this.Remarks;

            return str;
        }

        #region 为Ore中的数据构建的访问器
        public string Name
        {
            get { return Name_; }
            set { Name_ = Name; }
        }
        public byte Level
        {
            get { return Level_; }
            set { Level_ = Level; }
        }
        public List<string> MainElements
        {
            get { return MainElements_; }
            set { MainElements_ = MainElements; }
        }
        public List<string> Elements
        {
            get { return Elements_; }
            set { Elements_ = Elements; }
        }
        public List<Lode> InLodes
        {
            get { return InLodes_; }
            set { InLodes_ = InLodes; }
        }
        public string[] Byproducts
        {
            get { return Byproducts_; }
            set { Byproducts_ = Byproducts; }
        }
        public string Remarks
        {
            get { return Remarks_; }
            set { Remarks_ = Remarks; }
        }
        #endregion

        static public List<Ore> OreTable
        {
            get { return OreTable_; }
            set { OreTable_ = OreTable; }
        }
    }

    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}
